Mule : Programming Model
This page last changed on Oct 23, 2006 by [email protected].
The Programming ModelTo best understand the programming model and which bits you need write it helps to understand the different elements involved when processing messages and which of them you can control. Inbound Message Flow StageInbound message flow is triggered by data being received by a transport (such as a record being written to a DB or data written to a socket). The Mule transport provider is responsible for receiving this data and wrapping into a Mule Message. The Inbound router is responsible for applying routing logic to the inbound Message, such as Idem potency, re-sequencing, batching, etc.
EndpointThe Endpoint is used to receive messages from a transport. An endpoint is a configuration object that defines how data will be received and transformed by Mule. On the Endpoint you can configure the endpoint address, transport-specific configuration information, transactions and filters. For more information see Mule Endpoints. Inbound RouterInbound Routers control the inbound flow of events to a component and can re-sequence, aggregate or filter incoming messages. For example the IdempotentReceiver will reject any inbound messages that have already been received. The CorrelationResequencer will 'hold' a number of correlated events and hand them to the component in the correct order (based on the order they were dispatched).
Component Flow StageComponent flow starts when the MuleMessage is passed to the Model (Service container). Here the message will be passed to your Service object, but before that Interceptors and transformers can be invoked as part the inbound Message flow. Interceptor (pre)Interceptors are used to intercept message flow into your service component. They can be used trigger monitor/events or interrupt the flow of the message i.e. an authorisation interceptor could ensure that the current request has the correct credentials to invoke the service. Inbound TransformerInbound transformers are used to transform the inbound message from the underlying transport format to something that the Service Component needs. Transformers can be chained together and should be used for data-level transforms i.e. from one data-type/format to another.
Service InvocationThe service is the business logic. It can be a POJO, EJB, Remote Object or any other type of object. The Service component can be instantiated by the mule Model or it can be created by or stored in another container such as Spring, Hivemind, JNDI, Pico or Plexus. Invoking the ServiceTodo Implementing the Callable interfaceFor more information see the Writing Components chapter. Interceptor (post)If an interceptor configured on the Service is an Envelope Interceptor (it extends org.mule.interceptors.EnvelopeInterceptor) The after() method will be called allowing developers to hook in behaviour once the component has finished processing.
Outbound Flow StageThe Outbound message flow starts one the result message (output from a Service Invocation) is passed on from the Service. If there is no result message or no Outbound Router configured this stage is skipped. Outbound RouterThe Outbound Router is responsible for controlling how and where the message goes next. Mule defines a number of standard Outbound Routers including all those listed in the excellent Enterprise Integration Pattern Book plus some other routing patterns that we have seen. Outbound Routers allow for Content-based, Itinerary (routing slip), Dynamic and Header-based routing or a combination of these. Mule has standard routers for MessageSplitting, Multicasting and content-based routers. Outbound TransformerTODO Endpoint (outbound) Note that there can be zero or more endpoints that the event gets dispatched on depending on the Outbound Router logic. TODO
Messages and EventsTODO The UMOEventContextTODO
message-flow.gif (image/gif)
|
Document generated by Confluence on Nov 27, 2006 10:27 |